<template>
    <app-layout>
        <view class="page">
            <view class='top'>签到规则</view>
            <view class='rules'>
                <text class='rule' v-if="rules">{{rule}}</text>
                <text class='rule' v-else>{{activity_rule}}</text>
            </view>
        </view>
    </app-layout>
</template>

<script>
    import appLayout from "../../../components/basic-component/app-layout/app-layout.vue";
    import appFormId from "../../../components/basic-component/app-form-id/app-form-id.vue";

    import { mapState } from "vuex";

    export default {
        data() {
            return {
                rule: "",
                activity_rule: "",
                rules: true
            }
        },
        components: {
            "app-layout": appLayout,
            "app-form-id": appFormId
        },
        computed: {
            ...mapState({
                theme: state => state.mallConfig.theme,
            })
        },
        methods: {

            getList() {
                let that = this;
                that.$request({
                    url: that.$api.step.setting,
                }).then(response=>{
                    that.$hideLoading();
                    if(response.code == 0) {
                        that.rule = response.data.rule;
                        that.activity_rule = response.data.activity_rule;
                    }else {
                        uni.showToast({
                            title: response.msg,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                }).catch(response => {
                    that.$hideLoading();
                });
            },
        },

        onLoad(options) {
            let that = this;
            if (options.rule == 1) {
                that.rules = true;
            } else if (options.rule == 2) {
                that.rules = false;
            }
            that.getList();
        }
    }
</script>

<style scoped lang="scss">
    .page {
        padding-top: #{40rpx};
        color: #353535;
        background-color: white;
        position: absolute;
        width: 100%;
        height: 100%;
    }

    .top {
        margin-left: #{40rpx};
    }

    .rules{
        width: 100%;
        padding: #{20rpx} #{40rpx};
    }
</style>